package borge.web.teamspirit.client.data;

import java.util.List;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.NotPersistent;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import borge.web.teamspirit.client.interfaces.PersistentData;

/**
 * Class that represent an association cooperation.
 * An association provides app access via its own domain, and 
 * provides the application with input leagues and other info.
 * 
 * A team can register via this association, and that way get
 * access to the services that the association provides.
 * An example association would be LUGI, where a League maps to
 * for instance: "Innefotboll Herrar HT09" and the League has a list
 * of divisions, like 1a, 2b, 3c, and so on.
 *  
 * Add more info here...
 * @author Andreas Borglin
 *
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
public class Association implements PersistentData {


	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
    private String iEncodedKey;
    
	// The idea with this is that the app can be run in two different modes
	// Free mode - No connection to any sport association, teams create the series all by themselves
	// Associated mode - Connected to a sport association which provides league information that is used
	// when Teams create new series
	@Persistent
	private Boolean iFreeMode;
	
	// Name of the association
	@Persistent
    private String iName;
	
	// Association home page
    @Persistent
    private String iHomePage;
    
    // 
    @Persistent
    private String iAdminPersonKey;
    
    @Persistent
    private List<String> iUrlList;
    
    
    // Non-persistent data structures
    // Used internally by app
    // The lists below also reflect which unowned
    // children this entity has
    
    @NotPersistent
    private List<League> iLeagues;
    
    @NotPersistent
    private List<Team> iTeams;
    
    @NotPersistent
    private List<News> iNews;
    
    @NotPersistent
    private List<Event> iEvents;
    
    @NotPersistent
    private List<Comment> iGuestbook;
    
    public Association(){
    	
    	iName = "Lugi";
    	iFreeMode = false;
    	iHomePage = "www.lugi.se";
    }
    
    // more stuff like
	
    @Override
    public String toString(){
    	return iName;
    }
    
    public String getEncodedKey(){
    	return iEncodedKey;
    }
    
	@Override
	public String getDisplayingWidget() {
		// TODO Auto-generated method stub
		return null;
	}
	
	public void setName(String aName){
		iName = aName;
	}
	
	public void setAdminPerson(String aKey){
		iAdminPersonKey = aKey;
	}
	
	public void setMode(boolean aMode){
		iFreeMode = aMode;
	}

	
}
